<template>
	<view>
		<view class="cu-custom" :style="[{height:height + 'px'}]">
			<view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
				<view class="action" @tap="BackPage" v-if="isBack">
					<text class="cuIcon-back"></text>
					<slot name="backText"></slot>
				</view>
				<view class="content" :style="[{top:StatusBar + 'px'}]">
					<slot name="content"></slot>
				</view>
				<slot name="right"></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: 0 //this.StatusBar,
				// height: this.height
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar= this.StatusBar;
				var height= this.height;
				var bgImage = this.bgImage;
				var style =  {
					height:`${height}px`,
					'padding-top':`${StatusBar}px;`
				}
				if (this.bgImage) {
					style['background-image'] = `url(${bgImage})`
				}
				style = Object.assign(this.customStyle,style) 

				return style
			}
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
			height:{
				type:Number,
				default:48
			},
			customStyle:{
				type:Object,
				default:()=>{return {}}
			}
		},
		methods: {
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style>

</style>
